package com.loan.psychicloan.Util;

import android.os.CountDownTimer;
import android.widget.Button;

/**
 * Created by watilion on 2018/1/5 0005.
 */

public class MyCountDownTimer extends CountDownTimer {

    Button mButton;

    public MyCountDownTimer(Button mButton,long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
        this.mButton = mButton;

    }

    //计时过程
    @Override
    public void onTick(long l) {
        //防止计时过程中重复点击
        mButton.setClickable(false);
        mButton.setText("| "+l/1000+"s");

    }

    //计时完毕的方法
    @Override
    public void onFinish() {
        //重新给Button设置文字
        mButton.setText("发送验证码");
        //设置可点击
        mButton.setClickable(true);
    }
}
